package com.propertree.mailer.helper;

import java.util.Properties;

import javax.mail.PasswordAuthentication;
import javax.mail.Session;

import com.propertree.mailer.bean.EMailPartyInfo;

public class SessionHelper {

	public static Session createSession(final Properties props, final EMailPartyInfo emailPartyInfo) {
		Session session = null;
		try {
			session = Session.getInstance(props, new javax.mail.Authenticator() {
				protected PasswordAuthentication getPasswordAuthentication() {
					return new PasswordAuthentication(emailPartyInfo.getUserName(), emailPartyInfo.getPassword());
				}
			});
		} catch (Exception e) {
			e.printStackTrace();
		}
		return session;
	}
}
